/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.com.transportes.utilitario;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.sql.*;

public class CrearConexiones {
 public static final  int  ORACLE =1;
   public static  final int  MYSQL =2;
     public static  final int  SQL =3;
   public  static  int  tipo = MYSQL;
    public  static Connection  abrir () throws SQLException, ClassNotFoundException{
         if (  tipo==ORACLE){
             return abrirOracle();
         }
         if (  tipo==MYSQL){
             return abrirMySql();
         }
         if (  tipo==SQL){
             return abrirSql();
         }
         return  null;
    }
    public   static Connection  abrirOracle() throws SQLException{
        DriverManager.registerDriver(new oracle.jdbc.OracleDriver()); //hr  user1 12345
        Connection conn=
     DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","hr","oracle");
        System.out.println("conexion:"+ conn);
    return conn;
    }
    public  static Connection  abrirMySql()
           //cambiar la base de datos  base2
            //cambiar el password  123456789 . el pass por defecto es admin
            throws ClassNotFoundException, SQLException{
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost/transportes", "root", "");
        System.out.println("conexion:"+ con);
        return  con;
    }
    public  static Connection  abrirSql()
           //cambiar la base de datos  base2
            //cambiar el password  123456789 . el pass por defecto es admin
            throws ClassNotFoundException, SQLException{
        Class.forName("com.jnetdirect.jsql.JSQLDriver");
        Connection conn = DriverManager.getConnection("jdbc:JSQLConnect://172.17.2.218/database=incidencia/user=sa/password=sa");
        System.out.println("conexion:"+ conn);
        return  conn;
    }
}
